package com.tanhua.server.controller;

import com.tanhua.model.vo.PeachblossomVo;
import com.tanhua.server.service.PeachblossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 桃花传音Controller
 */
@RestController
public class PeachblossomController {
    @Autowired
    private PeachblossomService service;
    /**
     * 桃花传音-发送语音
     * POST /peachblossom
     * Body:    soundFile	文件
     * 返回: 无
     */
    @PostMapping("/peachblossom")
    public ResponseEntity save(MultipartFile soundFile) throws IOException {
        service.save(soundFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音-接收语音
     * GET /peachblossom
     * 返回数据 PeachblossomVo
     */
    @GetMapping("/peachblossom")
    public ResponseEntity find(){
        PeachblossomVo vo = service.find();
        return ResponseEntity.ok(vo);
    }
}
